<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Vue 2 过渡效果</title>
  <!-- 引入本地下载好的 vue.js -->
  <script src="../js/vue.js"></script>
  <style>
    /* 定义过渡效果 */
    .fade-enter-active, .fade-leave-active {
      transition: opacity 0.5s;
    }
    .fade-enter, .fade-leave-to {
      opacity: 0;
    }
  </style>
</head>
<body>
  <div id="app">
    <!-- 按钮 -->
    <button @click="toggle">切换显示</button>

    <!-- 过渡效果 -->
    <transition name="fade">
      <p v-if="isVisible">这是一个过渡效果！</p>
    </transition>
  </div>

  <script>
    new Vue({
      el: '#app',
      data() {
        return {
          isVisible: true // 控制元素显示/隐藏
        };
      },
      methods: {
        toggle() {
          this.isVisible = !this.isVisible; // 切换状态
        }
      }
    });
  </script>
</body>
</html>
